* Do File for: Owsiak, Andrew P. 2021. Conflict Management Trajectories: Theory and Evidence.
* Last updated: 29 July 2020
* Includes replication for main text and appendices.
* Analysis run using State 15

* Data sources (for details, see main text and Appendix A, online):
* Correlates of War Project. (2008) State System Membership List, v2008.1. Available at http://correlatesofwar.org. 
*Frazier, Derrick V. and William J. Dixon. (2006) “Third-Party Intermediaries and Negotiated Settlements, 1946-2000.” International Interactions 32(4):385-408.
*Klein, James P., Gary Goertz, and Paul F. Diehl. (2006) “The New Rivalry Dataset: Procedures and Patterns.” Journal of Peace Research 43(3):331–348. 
*Marshall, Monty G., Ted R. Gurr, and Keith Jaggers. (2019) Political Regime Characteristics and Transitions, 1800-2018: Dataset Users’ Manual. Available online at: https://www.systemicpeace.org/inscrdata.html.
*Palmer, Glenn, Vito D'Orazio, Michael Kenwick, and Matthew Lane. (2015) “The MID4 Dataset, 2002-2010: Procedures, Coding Rules and Description.” Conflict Management and Peace Science 32(2):222-242.
*Singer, J. David, Stuart Bremer, and John Stuckey. (1972) “Capability Distribution, Uncertainty, and Major Power War, 1820–1965.” In Peace, War, and Numbers, edited by Bruce Russett. Beverly Hills, CA: Sage. 


use "Replication Data for Trajectories - Theory and Evidence.dta", clear


*Table 1
*Text only. No replication.


*Table 2
tab Ycat if ngo==0 & unique==1
tab Ycat stateint if ngo==0 & unique==1, col
tab Ycat coalint if ngo==0 & unique==1, col
tab Ycat igoint if ngo==0 & unique==1, col


*Table B1
*Model 1
oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258), cluster(precmid)
*Model 2
oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & year<1990), cluster(precmid)
*Model 3
oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & year>1989), cluster(precmid)


*Table 3
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0
simqi
drop b1-b7


*Table B2
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & year<1990), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0
simqi
drop b1-b7


*Table B3
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & year>1989), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0
simqi
drop b1-b7


*Table B4
*Model 4
oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==1), cluster(precmid)
*Model 5
oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==0), cluster(precmid)


*Table 4
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==1), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0
simqi
drop b1-b7


*Table 5
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==0), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0
simqi
drop b1-b7


*Table B5
oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258), cluster(precmid)

oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==1), cluster(precmid)

oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc  intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==0), cluster(precmid)


*Table B6
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc  intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
drop b1-b17


*Table B7
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc  intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==1), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
drop b1-b17


*Table B8
set seed 8675309
estsimp oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc  intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & lagstsuccess==0), cluster(precmid)
setx Ystar1 1 Ystar3 1 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 1 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 0 Ystar4 1 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
setx Ystar1 0 Ystar3 0 Ystar4 0 disp_maj mean disp_endriv 0 cincratio mean hostlev mean fatality mean postcw 0 igoint 0 coalint 0 intvmaxpctmembercinc mean intvdempct mean
simqi
drop b1-b17


***************************************************

*Model Fit, Appendix C
*Likelihood Ratio Test
*Notes: (i) Clustering/robust standard errors are not possible; (ii) Both versions must have same number of observations, so force m1 into observations where the Ystar variables exist.
oprobit Ycat disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258 & Ystar1!=. & Ystar3!=. & Ystar4!=.)
estimates store m1
oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258)
estimates store m2
lrtest m1 m2

*Wald test
oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258), cluster(precmid)
test Ystar1 Ystar3 Ystar4

*Out-of-Sample Predictions
*Notes: (i) Removed outliers from list of MIDs under foreach commands (#611, #4273, #4258); ((ii) Model 1 lacks the Y*i variables, while Model 2 contains the Y*i variables.
*foreach x of numlist 7 26 27 28 51 61 173 199 200 259 354 606 1002 1013 1035 1046 1062 1068 1070 1074 1079 1084 1107 1108 1112 1173 1190 1193 1206 1238 1279 1280 1286 1289 1293 1304 1306 1312 1315 1340 1352 1353 1361 1363 1381 1385 1407 1408 1411 1441 1447 1480 1706 1792 1793 1806 2041 2082 2115 2119 2141 2150 2219 2231 2328 2339 2349 2357 2371 2540 2546 2572 2583 2631 2776 3020 3104 3195 3229 3427 3437 3551 3556 3557 3564 3630 3634 3635 3953 3957 4007 4013 4027 4066 4078 4088 4096 4116 4119 4121 4124 4128 4137 4140 4143 4156 4158 4164 4166 4192 4196 4223 4253 4257 4259 4269 4271 4280 4283 4291 4310 4339{
*oprobit Ycat disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc  intvdempct if (ngo==0 & precmid!=`x'), cluster(precmid)
*predict prob1_`x' prob2_`x' prob3_`x' prob4_`x' prob5_`x'
*}
*foreach n of numlist 1 2 3 4 5{
*gen model1prob_`n'=prob`n'_7 if precmid==7
*drop prob`n'_7
*foreach x of numlist 26 27 28 51 61 173 199 200 259 354 606 1002 1013 1035 1046 1062 1068 1070 1074 1079 1084 1107 1108 1112 1173 1190 1193 1206 1238 1279 1280 1286 1289 1293 1304 1306 1312 1315 1340 1352 1353 1361 1363 1381 1385 1407 1408 1411 1441 1447 1480 1706 1792 1793 1806 2041 2082 2115 2119 2141 2150 2219 2231 2328 2339 2349 2357 2371 2540 2546 2572 2583 2631 2776 3020 3104 3195 3229 3427 3437 3551 3556 3557 3564 3630 3634 3635 3953 3957 4007 4013 4027 4066 4078 4088 4096 4116 4119 4121 4124 4128 4137 4140 4143 4156 4158 4164 4166 4192 4196 4223 4253 4257 4259 4269 4271 4280 4283 4291 4310 4339{
*replace model1prob_`n'=prob`n'_`x' if precmid==`x'
*drop prob`n'_`x'
*}
*}

*foreach x of numlist 7 26 27 28 51 61 173 199 200 259 354 606  1002 1013 1035 1046 1062 1068 1070 1074 1079 1084 1107 1108 1112 1173 1190 1193 1206 1238 1279 1280 1286 1289 1293 1304 1306 1312 1315 1340 1352 1353 1361 1363 1381 1385 1407 1408 1411 1441 1447 1480 1706 1792 1793 1806 2041 2082 2115 2119 2141 2150 2219 2231 2328 2339 2349 2357 2371 2540 2546 2572 2583 2631 2776 3020 3104 3195 3229 3427 3437 3551 3556 3557 3564 3630 3634 3635 3953 3957 4007 4013 4027 4066 4078 4088 4096 4116 4119 4121 4124 4128 4137 4140 4143 4156 4158 4164 4166 4192 4196 4223 4253 4257  4259 4269 4271  4280 4283 4291 4310 4339{
*oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc  intvdempct if (ngo==0 & precmid!=`x'), cluster(precmid)
*predict prob1_`x' prob2_`x' prob3_`x' prob4_`x' prob5_`x'
*}
*foreach n of numlist 1 2 3 4 5{
*gen model2prob_`n'=prob`n'_7 if precmid==7
*drop prob`n'_7
*foreach x of numlist 26 27 28 51 61 173 199 200 259 354 606  1002 1013 1035 1046 1062 1068 1070 1074 1079 1084 1107 1108 1112 1173 1190 1193 1206 1238 1279 1280 1286 1289 1293 1304 1306 1312 1315 1340 1352 1353 1361 1363 1381 1385 1407 1408 1411 1441 1447 1480 1706 1792 1793 1806 2041 2082 2115 2119 2141 2150 2219 2231 2328 2339 2349 2357 2371 2540 2546 2572 2583 2631 2776 3020 3104 3195 3229 3427 3437 3551 3556 3557 3564 3630 3634 3635 3953 3957 4007 4013 4027 4066 4078 4088 4096 4116 4119 4121 4124 4128 4137 4140 4143 4156 4158 4164 4166 4192 4196 4223 4253 4257  4259 4269 4271  4280 4283 4291 4310 4339{
*replace model2prob_`n'=prob`n'_`x' if precmid==`x'
*drop prob`n'_`x'
*}
*}

*Brier scores.
*A brier score is the mean squared difference between the predicted probability and the observed outcome. So lower values are better predictions.
*Table C1.
oprobit Ycat Ystar1 Ystar3 Ystar4 disp_maj disp_endriv cincratio hostlev fatality postcw igoint coalint  intvmaxpctmembercinc intvdempct if (ngo==0 & precmid!=611 & precmid!=4273 & precmid!=4258), cluster(precmid)
brier Ycat1 model1prob_1 if e(sample)
brier Ycat1 model2prob_1 if e(sample)
brier Ycat2 model1prob_2 if e(sample)
brier Ycat2 model2prob_2 if e(sample)
brier Ycat3 model1prob_3 if e(sample)
brier Ycat3 model2prob_3 if e(sample)
brier Ycat4 model1prob_4 if e(sample)
brier Ycat4 model2prob_4 if e(sample)
brier Ycat5 model1prob_5 if e(sample)
brier Ycat5 model2prob_5 if e(sample)

*In addition, we can compare the predicted probabilities of Y=z when we know Y to be z. Higher values are better predictions, since it means more often predicting the true value of Y.
*Table C2
sum model1prob_1 if Ycat==1 & e(sample)
sum model2prob_1 if Ycat==1 & e(sample)
sum model1prob_2 if Ycat==2 & e(sample)
sum model2prob_2 if Ycat==2 & e(sample)
sum model1prob_3 if Ycat==3 & e(sample)
sum model2prob_3 if Ycat==3 & e(sample)
sum model1prob_4 if Ycat==4 & e(sample)
sum model2prob_4 if Ycat==4 & e(sample)
sum model1prob_5 if Ycat==5 & e(sample)
sum model2prob_5 if Ycat==5 & e(sample)
